<template>
    <div v-show="visible">
        <div class="grid_cont">
            <div style="display:flex;">
                <div style="width: 3px;height: 18px;background-color: rgba(204,53,47,1);"></div>
                <div style="margin-left:10px;font-size: 16px;line-height: 16px;">详情</div>
            </div>
            <div
                style="width: 100%;height: 1px;background-color:rgba(245,245,245,1);margin-top:16px;margin-bottom:20px;">
            </div>
            <div class="detail_cont">
                <div class="decont_top">
                    <div style="min-width: 70px;margin-left:42px;font-weight: 550;">民宿照片：</div>
                    <div class="contpt">
                        <div v-if="list && list.fileDOList && list.fileDOList.length > 0">
                            <el-row :gutter="10">
                                <div v-for="(item, index) in list.fileDOList" :key="index" class="ptlist">
                                    <el-col :span="24">
                                        <UploadImg disabled v-model="item.url" :limit="1" height="120px"
                                            width="120px" />
                                    </el-col>
                                </div>
                            </el-row>
                        </div>
                        <el-upload v-else disabled class="avatar-uploader"
                            style="position:relative;line-height: 0px !important;margin-bottom:8px;">
                            <el-icon disabled class="avatar-uploader-icon" />
                            <div style="position:absolute;cursor: not-allowed;user-select: none;color: #999;">暂无图片</div>
                        </el-upload>
                    </div>
                </div>
                <div class="decont_top">
                    <div style="min-width:42px;margin-left:70px;font-weight: 550;">店名：</div>
                    <div>{{ list.homestayName }}</div>
                </div>
                <div class="decont_top decont_top2">
                    <div style="min-width: 70px;margin-left:42px;margin-right:5px;font-weight: 550;">民宿标签：</div>
                    <el-row :gutter="10">
                        <div v-for="(item, index) in list.homestayLabel" :key="index" class="identity_style">
                            <el-col :span="24">
                                <div>{{ item }}</div>
                            </el-col>
                        </div>
                    </el-row>
                </div>
                <div class="decont_top">
                    <div style="min-width:42px;margin-left:70px;font-weight: 550;">地址：</div>
                    <div>{{ list.homestayAddr }}</div>
                </div>
                <div class="decont_top">
                    <div style="min-width:42px;margin-left:70px;font-weight: 550;">房型：</div>
                    <div>{{ list.houseType }}</div>
                </div>
                <div class="decont_top decont_top2">
                    <div style="min-width: 70px;font-weight: 550;">人均消费（元）：</div>
                    <div>{{ list.consumption }}</div>
                </div>
                <div class="decont_top decont_top2">
                    <div style="min-width: 70px;margin-left:42px;font-weight: 550;">基础设施：</div>
                    <div>{{ list.infrastructure }}</div>
                </div>
                <div class="decont_top decont_top2">
                    <div style="min-width: 70px;margin-left:42px;font-weight: 550;">联系电话：</div>
                    <div>{{ list.phone }}</div>
                </div>
                <div class="decont_top" style="display: block;">
                    <div style="min-width: 70px;margin-left:42px;font-weight: 550;">民宿简介：</div>
                    <div style="max-width:600px;line-height:30px;justify-Content: space-around;margin-left:42px;">{{
                        list.introduction }}</div>
                </div>
            </div>
            <div style="display:flex;margin-bottom:20px;">
                <div style="width: 3px;height: 18px;background-color: rgba(204,53,47,1);"></div>
                <div style="margin-left:10px;font-size: 16px;line-height: 16px;">审核</div>
            </div>
            <el-form :model="formData">
                <el-form-item label="审核结果：" style="margin-left:14px;">
                    <el-radio-group v-model="formData.result">
                        <el-radio label='2'>通过</el-radio>
                        <el-radio label='3'>驳回</el-radio>
                    </el-radio-group>
                </el-form-item>
                <el-form-item required prop="situation" v-if="formData.result === '3'" label="驳回说明：" :rules="[
                    { required: true, message: '驳回说明不能为空！' }]" style="margin-left: 4px;">
                    <el-input v-model="formData.situation" maxlength="20" style="width: 320px;" placeholder=""
                        show-word-limit type="textarea" />
                </el-form-item>
            </el-form>
        </div>
        <div class="grid_cont2">
            <el-button class="grid_btn" @click="gridCancel"
                style="background-color: rgba(255, 255, 255, 1);border: 1px solid rgba(187, 187, 187, 1);color: rgba(142, 142, 142, 1);">返回</el-button>
            <el-button class="grid_btn" @click="gridSure"
                style="background-color:#FF9900;border: 1px solid #FF9900;color:#fff;">审核</el-button>
        </div>
    </div>
</template>

<script lang="ts" setup>
import * as getTouristcenterApi from '@/api/appManagement/touristcenterManagement/index'
const formData = reactive({
    result: '2',
    situation: '',
})
const list = ref({})
const visible = ref(false)
const props = defineProps({
    homestayShow: {
        type: Boolean,
        default: false
    },
    editData: {
        type: Object
    }
})
const emit = defineEmits(['gethomestayShow', 'geteditData'])
watch(() => props.homestayShow, (val) => {
    visible.value = val
}, { immediate: true })
watch(() => props.editData, (val) => {
    if (val) {
        list.value = val
        formData.result = '2'
        formData.situation = ''
    }
}, { immediate: true })
/** 取消按钮操作 */
const gridCancel = () => {
    visible.value = false
    emit('gethomestayShow', visible.value)
    emit('geteditData', props.editData.pageNo)
}
/** 确定按钮操作 */
const gridSure = () => {
    const ResidentinfoData = {
        status: JSON.parse(formData.result),
        remark: formData.situation,
        id: props.editData.id,
        typeStr: props.editData.typeStr
    }
    if (formData.result === '2') {
        formData.situation = ''
        ElMessageBox.confirm(
            '是否确认通过审核?',
            '提示',
            {
                confirmButtonText: '确定',
                cancelButtonText: '取消',
                type: 'warning',
            }
        )
            .then(() => {
                getTouristcenterApi.getVisitorcenterInfo(ResidentinfoData).then((res) => {
                    if (res) {
                        ElMessage.success('审核通过！')
                        visible.value = false
                        emit('gethomestayShow', visible.value)
                        emit('geteditData', props.editData.pageNo)
                    }
                })
            })
            .catch(() => {
                ElMessage.info('已取消审核')
            })
        return
    }
    if (formData.result === '3' && formData.situation && formData.situation.trim()) {
        ElMessageBox.confirm(
            '是否确认驳回审核?',
            '提示',
            {
                confirmButtonText: '确定',
                cancelButtonText: '取消',
                type: 'warning',
            }
        )
            .then(() => {
                getTouristcenterApi.getVisitorcenterInfo(ResidentinfoData).then((res) => {
                    if (res) {
                        ElMessage.success('审核驳回成功！')
                        visible.value = false
                        emit('gethomestayShow', visible.value)
                        emit('geteditData', props.editData.pageNo)
                    }
                })
            })
            .catch(() => {
                ElMessage.info('已取消审核')
            })

    } else {
        ElMessage.warning('驳回说明为必填项不能为空！')
    }
}
onMounted(() => {
})
</script>
<style scoped>
.grid_cont {
    min-height: 600px;
    background: #fff;
}

.grid_cont2 {
    width: 100%;
    background: #fff;
    height: 65px;
    justify-Content: center;
    align-items: center;
    display: flex;
    padding: 0;
    box-shadow: 0px -2px 6px 0px rgba(188, 188, 188, 0.65);
}

.grid_btn {
    width: 80px;
    height: 30px;
    background-color: #FF9900;
    border: none;
    color: #fff;
}

.detail_cont {
    padding-left: 10px;
    line-height: 30px;
    margin-bottom: 30px;
}

.decont_top {
    display: flex;
    font-size: 14px;
    color: var(--el-text-color-regular);
    margin-top: 10px;
    margin-bottom: 10px;
}

.ptlist {
    margin-bottom: 10px;
}

.contpt {
    margin-top: 8px;
    margin-left: 42px;
}

.decont_top:first-child {
    margin-bottom: 0 !important;
    display: block;
}

.decont_top:nth-child(2) {
    margin-top: 0 !important;
}

.grid_btn:hover {
    opacity: 0.8;
}

::v-deep .avatar-uploader .el-upload {
    border: 1px solid var(--el-border-color);
    border-radius: 6px;
    position: relative;
    overflow: hidden;
    transition: var(--el-transition-duration-fast);
    cursor: not-allowed;
}

::v-deep .el-icon.avatar-uploader-icon {
    font-size: 28px;
    color: #8c939d;
    width: 120px;
    height: 120px;
    text-align: center;
    cursor: not-allowed;
    background-color: var(--el-disabled-bg-color);
}

::v-deep.avatar-uploader .el-upload-list {
    display: none !important;
}

::v-deep .upload-box .el-upload__tip {
    display: none;
}

.identity_style {
    min-width: 80px;
    height: 30px;
    line-height: 30px;
    text-align: center;
    border-radius: 5px;
    padding: 0 5px;
    margin-right: 10px;
    margin-bottom: 10px;
    font-size: 12px;
    border: none;
    cursor: pointer;
    border: 1px solid #CB1212;
    color: #D30E0E;
    font-weight: 550;
}

.decont_top:nth-child(3) {
    margin-bottom: 0 !important;
}

.decont_top:nth-child(4) {
    margin-top: 0 !important;
}

.identity_style:hover {
    opacity: 0.8;
}

::v-deep .upload .el-upload .el-upload-dragger {
    border: 1px solid var(--el-border-color-darker) !important;
}

::v-deep .upload .el-upload .el-upload-dragger:hover {
    border: 1.5px solid #ccc !important;
}

@media (min-width: 832px) and (max-width: 1000px) {
    .detail_cont {
        padding-left: 20px;
    }
}

@media (max-width: 770px) {
    .decont_top2 {
        display: flex !important;
    }
}
</style>